<?php
/**
 * Created by PhpStorm.
 * User: yy
 * Date: 2016/11/29
 * Time: 18:14
 */

namespace App\Services\Excel;


class ImportError
{
    const MOBILE_EXIST = 0;
    const SIMCARD_NOT_EXIST = 1;
    const SIMCARD_HAS_MOBILE = 2;
    const MISSING_INFO = 3;
    const SIMCARD_HAS_WX = 4;
    const NOT_HAS_KW = 5;
    const NOT_HAS_NAME = 6;
    const NOT_HAS_PWD = 7;
    const NOT_HAS_STATUS = 8;
    const NOT_HAS_EWMCONTENT = 9;
    const MOBILE_HAS_WX = 10;
    const NOT_KNOW_ERROR = 11;
    const NOT_HAS_MOBILE = 12;
    const MESSAGE = [
        '手机号已存在',
        '卡柜位不存在',
        '卡柜位已录入手机号',
        '数据错误',
        '卡柜已录入微信号',
        '未输入卡位',
        '未输入微信昵称',
        '未输入微信密码',
        '未输入账号状态',
        '未输入加好友二维码内容',
        '该手机已绑定微信号',
        '未知的错误',
        '卡柜未绑定手机号'
    ];

    private $error = [];

    public function addErrorIndex($error_index, $row_index) {
        $this->error[$error_index][] = $row_index;
    }

    public function getMessage() {
        $messages = [];
        foreach ($this->error as $key => $error_keys) {
            $message = '第 '
                . implode('、', $error_keys)
                . ' 行导入失败，'
                . self::MESSAGE[$key] . '。';
            array_push($messages, $message);
        }
        return $messages;
    }

}